import request from '@/utils/request'

// 查询答题记录列表
export function listAnswerrecord(query) {
  return request({
    url: '/wjq/answerrecord/list',
    method: 'get',
    params: query
  })
}

// 按题库ID查询答题记录列表
export function listAnswerrecordByBank(bankId) {
  return request({
    url: '/wjq/answerrecord/listByBank/' + bankId,
    method: 'get'
  })
}

// 按用户ID和题库ID查询答题记录
export function listAnswerrecordByUserAndBank(userId, bankId) {
  return request({
    url: '/wjq/answerrecord/listByUserAndBank',
    method: 'get',
    params: {
      userId: userId,
      bankId: bankId
    }
  })
}

// 查询答题记录详细
export function getAnswerrecord(id) {
  return request({
    url: '/wjq/answerrecord/' + id,
    method: 'get'
  })
}

// 新增答题记录
export function addAnswerrecord(data) {
  return request({
    url: '/wjq/answerrecord',
    method: 'post',
    data: data
  })
}

// 修改答题记录
export function updateAnswerrecord(data) {
  return request({
    url: '/wjq/answerrecord',
    method: 'put',
    data: data
  })
}

// 删除答题记录
export function delAnswerrecord(id) {
  return request({
    url: '/wjq/answerrecord/' + id,
    method: 'delete'
  })
}


// 批量查询题目详情
export function getBatchQuestions(ids) {
  // 验证参数
  if (!ids || ids.length === 0) {
    console.error("请提供有效的题目ID列表");
    return Promise.reject(new Error("缺少题目ID参数"));
  }
console.log("12345")
  return request({
    url: "/wjq/answerrecord/withQuestions/batch",
    method: "get",
    params: {
      ids: ids.join(",") // 将ID数组转换为逗号分隔的字符串
    }
  });
}
